]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
viewSelector: Don't reset the search entry if it has preedit text
authorRui Matos <tiagomatos@gmail.com>
Thu, 26 Feb 2015 18:21:52 +0000 (19:21 +0100)
committerRui Matos <tiagomatos@gmail.com>
Wed, 4 Mar 2015 14:25:35 +0000 (15:25 +0100)
If users click outside the search entry while it's empty we reset and
thus give up key focus. This means that when using an input method
with candidate popups, interacting with the popup with a mouse click
cancels the current input method context if there's no other text in
the entry besides the preedit string.

To avoid this we can check if the entry has preedit in addition to
checking if it has normal text.

https://bugzilla.gnome.org/show_bug.cgi?id=745167

js/ui/viewSelector.js
src/st/st-im-text.c
src/st/st-im-text.h

index ab22ff928144586fad4884c80bee52d1ba4d300c..6856f186524f9af52f336f4ccaf08f26005559ee 100644 (file)
@@ -552,7 +552,9 @@ const ViewSelector = new Lang.Class({
     _onCapturedEvent: function(actor, event) {
         if (event.type() == Clutter.EventType.BUTTON_PRESS) {
             let source = event.get_source();
-            if (source != this._text && this._text.text == '' &&
+            if (source != this._text &&
+                this._text.text == '' &&
+                !this._text.has_preedit () &&
                 !Main.layoutManager.keyboardBox.contains(source)) {
                 // the user clicked outside after activating the entry, but
                 // with no search term entered and no keyboard button pressed
index 5666e7acdd554813e01fce8fbf52dcb62f684a79..12b7e3fe4f83305bc4b88d82516e74f2aa3a5716 100644 (file)
@@ -67,6 +67,7 @@ struct _StIMTextPrivate
   GdkWindow *window;
 
   guint need_im_reset : 1;
+  guint has_preedit   : 1;
 };
 
 G_DEFINE_TYPE (StIMText, st_im_text, CLUTTER_TYPE_TEXT)
@@ -136,6 +137,8 @@ st_im_text_preedit_changed_cb (GtkIMContext *context,
                                    preedit_attrs,
                                    cursor_pos);
 
+  imtext->priv->has_preedit = preedit_str && *preedit_str;
+
   g_free (preedit_str);
   pango_attr_list_unref (preedit_attrs);
 }
@@ -622,3 +625,17 @@ st_im_text_get_input_hints (StIMText *imtext)
 
   return hints;
 }
+
+/**
+ * st_im_text_has_preedit:
+ * @imtext: a #StIMText
+ *
+ * Returns: wether @imtext currently has preedit text
+ */
+gboolean
+st_im_text_has_preedit (StIMText *imtext)
+{
+  g_return_val_if_fail (ST_IS_IM_TEXT (imtext), FALSE);
+
+  return imtext->priv->has_preedit;
+}
index c97975ae91565ea5eeeb34df1afd354b7fed77aa..4c96248b8254e7b3b1423a91ef5ba27c54a1695d 100644 (file)
@@ -67,6 +67,7 @@ GtkInputPurpose st_im_text_get_input_purpose (StIMText       *imtext);
 void            st_im_text_set_input_hints   (StIMText       *imtext,
                                               GtkInputHints   hints);
 GtkInputHints   st_im_text_get_input_hints   (StIMText       *imtext);
+gboolean        st_im_text_has_preedit       (StIMText       *imtext);
 
 void            st_im_text_set_event_window  (GdkWindow      *window);